<template>
  <div class="withdrawRegister">
    <cus-search class="mb_20">
      <cus-search-item>
        <Form :model="form0" :label-width="80">
          <FormItem label="姓名" class="mr_48 mb_20" :label-width="50">
            <Input v-model.trim="form0.jiaoHuoName" clearable style="width: 200px" maxlength="20"
              placeholder="请输入姓名"></Input>
          </FormItem>
          <FormItem label="人员单位" class="mr_48 mb_20">
            <Select v-model="form0.type" style="width: 200px" clearable placeholder="请选择人员单位">
              <Option :value="v.id" v-for="(v, i) in danweiList" :key="i">{{
          v.name
        }}</Option>
            </Select>
          </FormItem>
          <FormItem label="登记时间" class="mr_48 mb_20">
            <cus-cascadeDate :startTime.sync="form0.startTime" :endTime.sync="form0.endTime" :need-init="false"
              :only-month="true" type="datetime"></cus-cascadeDate>
          </FormItem>
          <cusButton class="mr_20" type="primary" @onClick="onInit">查询</cusButton>
        </Form>
      </cus-search-item>
    </cus-search>

    <cus-card :title="title" :showTitle="true">
      <div slot="header-right" style="display: flex; justify-content: flex-end; flex: 1">
        <cusButton type="primary" class="mr_10" @onClick="onSave">保存</cusButton>
        <cusButton type="primary" @onClick="$refs['cusUploadModal'].show()">导出</cusButton>
      </div>
      <Tabs type="card" v-model="current" @on-click="onTabClick">
        <TabPane label="交伙登记" name="1">
          <Form ref="formValidate1" :model="form1" label-position="left">
            <cusTable border :loading="form1.loading" :columns="columns1" :data="form1.data" :bottomClass="['amount']">
              <template slot-scope="{ row, index }" slot="columns1">
                {{
          row.createtime
            ? new Date(row.createtime).Format("yyyy-MM-dd")
            : new Date().Format("yyyy-MM-dd")
        }}
              </template>
              <template slot-scope="{ row, index }" slot="jiaohuoname">
                <FormItem v-if="!row.jiaohuoId" class="cookTable-item" :label-width="0"
                  :prop="`data.${index}.jiaohuoname`" :rules="{
          required: true,
          type: 'string',
          message: '姓名不能为空',
          trigger: 'blur',
        }">
                  <Input type="text" v-model="form1.data[index].jiaohuoname" maxlength="30" clearable
                    placeholder="姓名"></Input>
                </FormItem>
                <div v-else>{{ form1.data[index].jiaohuoname }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="type">
                <FormItem v-if="!row.jiaohuoId" class="cookTable-item" :label-width="0" :prop="`data.${index}.type`"
                  :rules="{
          required: true,
          type: 'string',
          message: '交伙类型不能为空',
          trigger: 'change',
        }">
                  <Select v-model="form1.data[index].type" clearable transfer placeholder="选择交伙类型"
                    @on-change="(v) => onTypeChange(row, 2, index, null, true)">
                    <Option :value="v.id" v-for="(v, i) in danweiList" :key="i">{{
          v.name
        }}</Option>
                  </Select>
                </FormItem>
                <div v-else>{{ form1.data[index].type }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="standardstr">
                <FormItem v-if="!row.jiaohuoId" class="cookTable-item" :label-width="0"
                  :prop="`data.${index}.standardstr`" :rules="{
          required: true,
          type: 'string',
          message: '交伙标准不能为空',
        }">
                  <Select v-model="form1.data[index].standardstr" clearable transfer placeholder="选择交伙标准"
                    @on-change="(v) => onTypeChange(row, 3, index)">
                    <Option :value="v.name" v-for="(v, i) in form1.data[index].partnerList" :key="v.name">{{ v.name }}
                    </Option>
                  </Select>
                </FormItem>
                <div v-else>{{ form1.data[index].standardstr }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="jhabstract">
                <Tooltip :content="row.jhabstract" :max-width="200" placement="top-start" v-if="row.jiaohuoId">
                  <div class="ellipsis" style="width: 50px">
                    {{ row.jhabstract }}
                  </div>
                </Tooltip>
                <Input type="text" v-model="form1.data[index].jhabstract" maxlength="30" clearable placeholder="摘要"
                  v-else></Input>
              </template>
              <template slot-scope="{ row, index }" slot="startdate">
                <FormItem v-if="!row.jiaohuoId" class="cookTable-item" :label-width="0"
                  :prop="`data.${index}.startdate`" :rules="{
          required: true,
          type: 'date',
          message: '交伙日期不能为空',
          trigger: 'change',
        }">
                  <DatePicker type="date" placeholder="交伙日期" @on-change="(v) => onDateChange(v, index)" transfer
                    clearabled v-model="form1.data[index].startdate" />
                </FormItem>
                <div v-else>{{ form1.data[index].startdate }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="startcan">
                <FormItem v-if="!row.jiaohuoId" class="cookTable-item" :label-width="0" :prop="`data.${index}.startcan`"
                  :rules="{
          required: true,
          type: 'number',
          message: '餐次不能为空',
          trigger: 'change',
        }">
                  <Select v-model="form1.data[index].startcan" @on-change="(v) => onDateChange(v, index)" clearable
                    transfer placeholder="选择餐次">
                    <Option :value="v.id" v-for="(v, i) in d_mealList" :key="i">{{
          v.name
        }}</Option>
                  </Select>
                </FormItem>
                <div v-else>
                  {{ d_mealList.find((v) => v.id == form1.data[index].startcan).name }}
                </div>
              </template>
              <template slot-scope="{ row, index }" slot="enddate">
                <FormItem v-if="!row.jiaohuoId" class="cookTable-item" :label-width="0" :prop="`data.${index}.enddate`"
                  :rules="{
          required: true,
          type: 'date',
          message: '停伙日期不能为空',
          trigger: 'change',
        }">
                  <DatePicker type="date" placeholder="停伙日期" @on-change="(v) => onDateChange(v, index)" transfer
                    clearabled v-model="form1.data[index].enddate" />
                </FormItem>
                <div v-else>{{ form1.data[index].enddate }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="endcan">
                <FormItem v-if="!row.jiaohuoId" class="cookTable-item" :label-width="0" :prop="`data.${index}.endcan`"
                  :rules="{
          required: true,
          type: 'number',
          message: '餐次不能为空',
          trigger: 'change',
        }">
                  <Select v-model="form1.data[index].endcan" @on-change="(v) => onDateChange(v, index)" clearable
                    transfer placeholder="选择餐次">
                    <Option :value="v.id" v-for="(v, i) in d_mealList" :key="i">{{
          v.name
        }}</Option>
                  </Select>
                </FormItem>
                <div v-else>
                  {{ d_mealList.find((v) => v.id == form1.data[index].endcan).name }}
                </div>
              </template>
              <template slot-scope="{ row, index }" slot="days">{{ row.days }}</template>
              <template slot-scope="{ row, index }" slot="standardmoney">{{
          row.standardmoney
        }}</template>
              <template slot-scope="{ row, index }" slot="jbmoney">{{
            row.jbmoney
          }}</template>
              <template slot-scope="{ row, index }" slot="money">{{
            row.money
          }}</template>
              <template slot-scope="{ row, index }" slot="operation">
                <cus-button type="text" size="small" :style="{ color: '#1E6FFF', padding: '0 8px' }"
                  @onClick="onAdd(index)">新增</cus-button>
              </template>
            </cusTable>
            <div class="mt_16 amount" style="display: flex; justify-content: flex-end">
              <!-- 总金额: {{ form1.total }}元 -->
            </div>
          </Form>
        </TabPane>
        <TabPane label="退伙登记" name="2">
          <Form ref="formValidate2" :model="form2" label-position="left">
            <cusTable border :loading="form2.loading" :columns="columns2" :data="form2.data" :bottomClass="['amount']">
              <template slot-scope="{ row, index }" slot="columns1">
                {{ new Date().getTime() | formatTime("yyyy-MM-dd") }}
              </template>
              <template slot-scope="{ row, index }" slot="tuihuoname">
                <FormItem v-if="!row.tuihuoId" class="cookTable-item" :label-width="0"
                  :prop="`data.${index}.tuihuoname`" :rules="{
          required: true,
          type: 'string',
          message: '姓名不能为空',
          trigger: 'blur',
        }">
                  <Input type="text" v-model="form2.data[index].tuihuoname" maxlength="30" clearable
                    placeholder="姓名"></Input>
                </FormItem>
                <div v-else>{{ form2.data[index].tuihuoname }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="type">
                <FormItem v-if="!row.tuihuoId" class="cookTable-item" :label-width="0" :prop="`data.${index}.type`"
                  :rules="{
          required: true,
          type: 'string',
          message: '退伙类型不能为空',
          trigger: 'change',
        }">
                  <Select v-model="form2.data[index].type" clearable transfer placeholder="选择退伙类型"
                    @on-change="(v) => onTypeChange(row, 2, index, null, true)">
                    <Option :value="v.id" v-for="(v, i) in danweiList" :key="i">{{
          v.name
        }}</Option>
                  </Select>
                </FormItem>
                <div v-else>{{ form2.data[index].type }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="standardstr">
                <FormItem v-if="!row.tuihuoId" class="cookTable-item" :label-width="0"
                  :prop="`data.${index}.standardstr`" :rules="{
          required: true,
          type: 'string',
          message: '退伙标准不能为空',
        }">
                  <Select v-model="form2.data[index].standardstr" clearable transfer placeholder="选择退伙标准"
                    @on-change="(v) => onTypeChange(row, 3, index)">
                    <Option :value="v.id" v-for="(v, i) in form2.data[index].partnerList" :key="i">{{ v.name }}</Option>
                  </Select>
                </FormItem>
                <div v-else>{{ form2.data[index].standardstr }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="thabstract">
                <Tooltip :content="row.thabstract" :max-width="200" placement="top-start" v-if="row.tuihuoId">
                  <div class="ellipsis" style="width: 50px">
                    {{ row.thabstract }}
                  </div>
                </Tooltip>
                <Input type="text" v-model="form2.data[index].thabstract" maxlength="30" clearable placeholder="摘要"
                  v-else></Input>
              </template>
              <template slot-scope="{ row, index }" slot="tinghuodate">
                <FormItem v-if="!row.tuihuoId" class="cookTable-item" :label-width="0"
                  :prop="`data.${index}.tinghuodate`" :rules="{
          required: true,
          type: 'date',
          message: '停伙日期不能为空',
          trigger: 'change',
        }">
                  <!-- :options="form2.data[index].options" -->
                  <DatePicker type="date" placeholder="停伙日期" @on-change="(v) => onDateChange(v, index)" transfer
                    clearabled v-model="form2.data[index].tinghuodate" />
                </FormItem>
                <div v-else>{{ form2.data[index].tinghuodate }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="tinghuocan">
                <FormItem v-if="!row.tuihuoId" class="cookTable-item" :label-width="0"
                  :prop="`data.${index}.tinghuocan`" :rules="{
          required: true,
          type: 'number',
          message: '餐次不能为空',
          trigger: 'change',
        }">
                  <Select v-model="form2.data[index].tinghuocan" @on-change="(v) => onDateChange(v, index)" clearable
                    transfer placeholder="选择餐次">
                    <Option :value="v.id" v-for="(v, i) in d_mealList" :key="i">{{
          v.name
        }}</Option>
                  </Select>
                </FormItem>
                <div v-else>
                  {{ d_mealList.find((v) => v.id == form2.data[index].tinghuocan).name }}
                </div>
              </template>
              <template slot-scope="{ row, index }" slot="shouhuodate">
                <FormItem v-if="!row.tuihuoId" class="cookTable-item" :label-width="0"
                  :prop="`data.${index}.shouhuodate`" :rules="{
          required: true,
          type: 'date',
          message: '起伙日期不能为空',
          trigger: 'change',
        }">
                  <!-- :options="form2.data[index].options" -->
                  <DatePicker type="date" placeholder="起伙日期" @on-change="(v) => onDateChange(v, index)" transfer
                    clearabled v-model="form2.data[index].shouhuodate" />
                </FormItem>
                <div v-else>{{ form2.data[index].shouhuodate }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="shouhuocan">
                <FormItem v-if="!row.tuihuoId" class="cookTable-item" :label-width="0"
                  :prop="`data.${index}.shouhuocan`" :rules="{
          required: true,
          type: 'number',
          message: '餐次不能为空',
          trigger: 'change',
        }">
                  <Select v-model="form2.data[index].shouhuocan" @on-change="(v) => onDateChange(v, index)" clearable
                    transfer placeholder="选择餐次">
                    <Option :value="v.id" v-for="(v, i) in d_mealList" :key="i">{{
          v.name
        }}</Option>
                  </Select>
                </FormItem>
                <div v-else>
                  {{ d_mealList.find((v) => v.id == form2.data[index].shouhuocan).name }}
                </div>
              </template>
              <template slot-scope="{ row, index }" slot="days">{{ row.days }}</template>
              <template slot-scope="{ row, index }" slot="hsmoney">{{
          row.hsmoney
        }}</template>
              <template slot-scope="{ row, index }" slot="jbmoney">{{
            row.jbmoney
          }}</template>
              <template slot-scope="{ row, index }" slot="sickpersonnelstandard">{{
            row.sickpersonnelstandard
          }}</template>
              <template slot-scope="{ row, index }" slot="tuihuomoney">{{
            row.tuihuomoney
          }}</template>
              <template slot-scope="{ row, index }" slot="operation">
                <cus-button type="text" size="small" :style="{ color: '#1E6FFF', padding: '0 8px' }"
                  @onClick="onAdd">新增</cus-button>
              </template>
            </cusTable>
            <div class="mt_16 amount" style="display: flex; justify-content: flex-end">
              <!-- 总金额: {{ form2.total }}元 -->
            </div>
          </Form>
        </TabPane>
        <TabPane label="客饭登记" name="3">
          <Form ref="formValidate3" :model="form3" label-position="left">
            <cusTable border :loading="form3.loading" :columns="columns3" :data="form3.data" :bottomClass="['amount']">
              <template slot-scope="{ row, index }" slot="columns1">
                {{ new Date().getTime() | formatTime("yyyy-MM-dd") }}
              </template>
              <template slot-scope="{ row, index }" slot="lianxiname">
                <FormItem v-if="!row.fankeId" class="cookTable-item" :label-width="0" :prop="`data.${index}.lianxiname`"
                  :rules="{
          required: true,
          type: 'string',
          message: '姓名不能为空',
          trigger: 'blur',
        }">
                  <Input type="text" v-model="form3.data[index].lianxiname" maxlength="30" clearable placeholder="姓名"
                    @on-change="(v) => onNameChange(row, v, index)"></Input>
                </FormItem>
                <div v-else>{{ form3.data[index].lianxiname }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="fankename">
                <FormItem v-if="!row.fankeId" class="cookTable-item" :label-width="0" :prop="`data.${index}.fankename`"
                  :rules="{
          required: true,
          type: 'string',
          message: '客饭姓名不能为空',
          trigger: 'change',
        }">
                  <Input type="text" v-model="form3.data[index].fankename" maxlength="30" clearable
                    placeholder="客饭姓名"></Input>
                </FormItem>
                <div v-else>{{ form3.data[index].fankename }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="standardstr">
                <FormItem v-if="!row.fankeId" class="cookTable-item" :label-width="0"
                  :prop="`data.${index}.standardstr`" :rules="{
          required: true,
          type: 'string',
          message: '关系不能为空',
          trigger: 'change',
        }">
                  <Select v-model="form3.data[index].standardstr" clearable transfer placeholder="选择关系"
                    @on-change="(v) => onTypeChange(row, 3, index, v)">
                    <Option :value="v.id" v-for="(v, i) in form3.data[index].partnerList" :key="i">{{ v.name }}</Option>
                  </Select>
                </FormItem>
                <div v-else>{{ form3.data[index].standardstr }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="fkabstract">
                <Tooltip :content="row.fkabstract" :max-width="200" placement="top-start" v-if="row.fankeId">
                  <div class="ellipsis" style="width: 50px">
                    {{ row.fkabstract }}
                  </div>
                </Tooltip>
                <Input type="text" v-model="form3.data[index].fkabstract" maxlength="30" clearable placeholder="摘要"
                  v-else></Input>
              </template>
              <template slot-scope="{ row, index }" slot="tinghuodate">

                <FormItem v-if="!row.fankeId" class="cookTable-item" :label-width="0"
                  :prop="`data.${index}.tinghuodate`" :rules="{
          required: true,
          type: 'date',
          message: '停伙日期不能为空',
          trigger: 'change',

        }">

                  <DatePicker type="date" placeholder="停伙日期" @on-change="(v) => onDateChange(v, index)" transfer
                    clearabled :options="disabledTime" v-model="form3.data[index].tinghuodate" />
                </FormItem>
                <div v-else>{{ form3.data[index].tinghuodate }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="tinghuocan">
                <FormItem v-if="!row.fankeId" class="cookTable-item" :label-width="0" :prop="`data.${index}.tinghuocan`"
                  :rules="{
          required: true,
          type: 'number',
          message: '餐次不能为空',
          trigger: 'change',
        }">
                  <Select v-model="form3.data[index].tinghuocan" @on-change="(v) => onDateChange(v, index)" clearable
                    transfer placeholder="选择餐次">
                    <Option :value="v.id" v-for="(v, i) in d_mealList" :key="i">{{
          v.name
        }}</Option>
                  </Select>
                </FormItem>
                <div v-else>
                  {{ d_mealList.find((v) => v.id == form3.data[index].tinghuocan).name }}
                </div>
              </template>
              <template slot-scope="{ row, index }" slot="qihuodate">
                <FormItem v-if="!row.fankeId" class="cookTable-item" :label-width="0" :prop="`data.${index}.qihuodate`"
                  :rules="{
          required: true,
          type: 'date',
          message: '起伙日期不能为空',
          trigger: 'change',
        }">
                  <DatePicker type="date" placeholder="起伙日期" @on-change="(v) => onDateChange(v, index)" transfer
                    clearabled v-model="form3.data[index].qihuodate" />
                </FormItem>
                <div v-else>{{ form3.data[index].qihuodate }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="qihuocan">
                <FormItem v-if="!row.fankeId" class="cookTable-item" :label-width="0" :prop="`data.${index}.qihuocan`"
                  :rules="{
          required: true,
          type: 'number',
          message: '餐次不能为空',
          trigger: 'change',
        }">
                  <Select v-model="form3.data[index].qihuocan" @on-change="(v) => onDateChange(v, index)" clearable
                    transfer placeholder="选择餐次">
                    <Option :value="v.id" v-for="(v, i) in d_mealList" :key="i">{{
          v.name
        }}</Option>
                  </Select>
                </FormItem>
                <div v-else>
                  {{ d_mealList.find((v) => v.id == form3.data[index].qihuocan).name }}
                </div>
              </template>
              <template slot-scope="{ row, index }" slot="days">{{ row.days }}</template>
              <template slot-scope="{ row, index }" slot="cans">{{ row.cans }}</template>
              <template slot-scope="{ row, index }" slot="guojie">
                <InputNumber v-if="!row.fankeId" style="width: 100%" size="large" :precision="2" :min="0"
                  :max="form3.data[index].days ? parseFloat(form3.data[index].days) : 0"
                  @on-change="(v) => onDateChange(v, index)" v-model="form3.data[index].guojie" placeholder="过节天数">
                </InputNumber>
                <div v-else>{{ row.guojie }}</div>
              </template>
              <template slot-scope="{ row, index }" slot="standardmoney">{{
          row.standardmoney
        }}</template>
              <template slot-scope="{ row, index }" slot="jbmoney">{{
            row.jbmoney
          }}</template>
              <template slot-scope="{ row, index }" slot="guojieMoney">{{
            row.guojieMoney
          }}</template>
              <template slot-scope="{ row, index }" slot="money">{{
                row.money
                }}</template>
              <template slot-scope="{ row, index }" slot="operation">
                <cus-button type="text" size="small" :style="{ color: '#1E6FFF', padding: '0 8px' }"
                  @onClick="onAdd(row, index)">新增</cus-button>
              </template>
            </cusTable>
            <div class="mt_16 amount" style="display: flex; justify-content: flex-end">
              <!-- 总金额: {{ form3.total }}元 -->
            </div>
          </Form>
        </TabPane>
      </Tabs>
    </cus-card>
    <!-- <cus-footer>
      <div
        style="width: 100%; display: flex; justify-content: flex-end; padding-right: 20px"
      >
        <cus-page
          :data="pages1"
          class="mb_10"
          v-if="current == 1"
          @pageChange="onInit"
        ></cus-page>
        <cus-page
          :data="pages2"
          class="mb_10"
          v-if="current == 2"
          @pageChange="onInit"
        ></cus-page>
        <cus-page
          :data="pages3"
          class="mb_10"
          v-if="current == 3"
          @pageChange="onInit"
        ></cus-page>
      </div>
    </cus-footer> -->
    <Spin fix v-if="form0.loading"></Spin>

    <cus-uploadModal ref="cusUploadModal" :tempSrc="excelPartnerRecord" :showUpload="false" uploadLabel="导出基础数据"
      accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
      @onOk="onInit">
    </cus-uploadModal>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import {
  getPartnerList,
  getPartnerInfoList,
  addPartner,
  addCancelPartner,
  getDinnerParams,
  getCancelPartnerInfoList,
  getFanKeInfoList,
  getApplyDays,
  addFanKe,
  excelPartnerRecord,
  excelCancelPartnerRecord,
  excelApplyRecord
} from "@/api/business/business";

export default {
  name: "withdrawRegister",
  data() {
    return {
      current: "1",
      form0: {
        loading: false,
        type: "",
        jiaoHuoName: "",
        startTime: "",
        endTime: ""
      },
      form1: {
        loading: false,
        total: "",
        data: []
      },
      form2: {
        loading: false,
        total: "",
        data: []
      },
      form3: {
        loading: false,
        total: "",
        data: []
      },
      columns1: [
        {
          title: " ",
          children: [
            {
              width: 70,
              title: "序号",
              key: "name",
              type: "index",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "登记时间",
              width: 150,
              slot: "columns1",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "姓名",
              minWidth: 130,
              slot: "jiaohuoname",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "交伙类型",
              width: 150,
              slot: "type",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "交伙标准",
              width: 150,
              slot: "standardstr",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "摘要",
              minWidth: 120,
              slot: "jhabstract",
              align: "center"
            }
          ]
        },
        {
          title: "交伙日期",
          align: "center",
          children: [
            {
              title: "日期",
              width: 150,
              slot: "startdate",
              align: "center"
            },
            {
              title: "餐次",
              width: 130,
              slot: "startcan",
              align: "center"
            }
          ]
        },
        {
          title: "停伙日期",
          align: "center",
          children: [
            {
              title: "日期",
              width: 150,
              slot: "enddate",
              align: "center"
            },
            {
              title: "餐次",
              width: 130,
              slot: "endcan",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "交伙天数",
              minWidth: 120,
              slot: "days",
              align: "center"
            }
          ]
        },
        {
          title: "伙食费标准",
          align: "center",
          children: [
            {
              title: "金额",
              minWidth: 120,
              slot: "standardmoney",
              align: "center"
            }
          ]
        },
        {
          title: "军粮差价补贴",
          align: "center",
          children: [
            {
              title: "金额",
              minWidth: 130,
              slot: "jbmoney",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "交伙总金额",
              minWidth: 120,
              slot: "money",
              align: "center"
            }
          ]
        },
        {
          title: "操作",
          width: 80,
          fixed: "right",
          slot: "operation",
          align: "center"
        }
      ],
      columns2: [
        {
          title: " ",
          children: [
            {
              width: 70,
              title: "序号",
              key: "name",
              type: "index",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "登记时间",
              width: 150,
              slot: "columns1",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "姓名",
              minWidth: 130,
              slot: "tuihuoname",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "退伙类型",
              width: 150,
              slot: "type",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "退伙标准",
              width: 150,
              slot: "standardstr",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "摘要",
              minWidth: 120,
              slot: "thabstract",
              align: "center"
            }
          ]
        },
        {
          title: "停伙日期",
          align: "center",
          children: [
            {
              title: "日期",
              width: 150,
              slot: "tinghuodate",
              align: "center"
            },
            {
              title: "餐次",
              width: 130,
              slot: "tinghuocan",
              align: "center"
            }
          ]
        },
        {
          title: "起伙日期",
          align: "center",
          children: [
            {
              title: "日期",
              width: 150,
              slot: "shouhuodate",
              align: "center"
            },
            {
              title: "餐次",
              width: 130,
              slot: "shouhuocan",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "退伙天数",
              minWidth: 120,
              slot: "days",
              align: "center"
            }
          ]
        },
        {
          title: "伙食费标准",
          align: "center",
          children: [
            {
              title: "金额",
              minWidth: 120,
              slot: "hsmoney",
              align: "center"
            }
          ]
        },
        {
          title: "军粮差价补贴",
          align: "center",
          children: [
            {
              title: "金额",
              minWidth: 130,
              slot: "jbmoney",
              align: "center"
            }
          ]
        },
        {
          title: "伤病员专项标准",
          align: "center",
          children: [
            {
              title: "金额",
              minWidth: 140,
              slot: "sickpersonnelstandard",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "退伙总金额",
              minWidth: 120,
              slot: "tuihuomoney",
              align: "center"
            }
          ]
        },
        {
          title: "操作",
          width: 80,
          fixed: "right",
          slot: "operation",
          align: "center"
        }
      ],
      columns3: [
        {
          title: " ",
          children: [
            {
              width: 70,
              title: "序号",
              key: "name",
              type: "index",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "登记时间",
              width: 150,
              slot: "columns1",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "姓名",
              minWidth: 130,
              slot: "lianxiname",
              align: "center"
            }
          ]
        },
        {
          title: "与部队人员关系",
          align: "center",
          children: [
            {
              title: "客饭姓名",
              width: 150,
              slot: "fankename",
              align: "center"
            },
            {
              title: "关系",
              width: 150,
              slot: "standardstr",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "摘要",
              minWidth: 120,
              slot: "fkabstract",
              align: "center"
            }
          ]
        },
        {
          title: "起伙日期",
          align: "center",
          children: [
            {
              title: "日期",
              width: 150,
              slot: "qihuodate",
              align: "center"
            },
            {
              title: "餐次",
              width: 130,
              slot: "qihuocan",
              align: "center"
            }
          ]
        },
        {
          title: "停伙日期",
          align: "center",
          children: [
            {
              title: "日期",
              width: 150,
              slot: "tinghuodate",
              align: "center"
            },
            {
              title: "餐次",
              width: 130,
              slot: "tinghuocan",
              align: "center"
            }
          ]
        },
        {
          title: "报销天数",
          align: "center",
          children: [
            {
              title: "天数",
              minWidth: 120,
              slot: "days",
              align: "center"
            },
            {
              title: "剩余天数",
              minWidth: 120,
              slot: "cans",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "过节天数",
              minWidth: 130,
              slot: "guojie",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          align: "center",
          children: [
            {
              title: "客饭标准",
              minWidth: 120,
              slot: "standardmoney",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          align: "center",
          children: [
            {
              title: "过节补贴标准",
              minWidth: 130,
              slot: "guojieMoney",
              align: "center"
            }
          ]
        },
        {
          title: " ",
          children: [
            {
              title: "总金额",
              minWidth: 120,
              slot: "money",
              align: "center"
            }
          ]
        },
        {
          title: "操作",
          width: 80,
          fixed: "right",
          slot: "operation",
          align: "center"
        }
      ],

      danweiList: [],
      mealParams: [],

      pages1: {
        page: 1,
        pageSize: 20,
        pageTotal: 0
      },
      pages2: {
        page: 1,
        pageSize: 20,
        pageTotal: 0
      },
      pages3: {
        page: 1,
        pageSize: 20,
        pageTotal: 0
      }
    };
  },
  computed: {
    ...mapGetters(["d_partnerList", "d_mealList"]),
    excelPartnerRecord() {
      let methods = "";
      if (this.current == 1) {
        methods += excelPartnerRecord();
      } else if (this.current == 2) {
        methods += excelCancelPartnerRecord();
      } else if (this.current == 3) {
        methods += excelApplyRecord();
      }
      methods += `&startDate=${this.form0.startTime}`;
      methods += `&endDate=${this.form0.endTime}`;
      methods += `&type=${this.form0.type}`;
      return methods;
    },
    title() {
      if (this.current == 1) {
        return "交伙登记";
      } else if (this.current == 2) {
        return "退伙登记";
      } else if (this.current == 3) {
        return "客饭登记";
      }
    },

  },
  mounted() {
    this.getDinnerParamsApi();
    this.onInit();
  },
  methods: {
    onInit() {
      if (this.current == 1) {
        this.getPartnerInfoListApi();
      } else if (this.current == 2) {
        this.getCancelPartnerInfoListApi();
      } else if (this.current == 3) {
        this.getFanKeInfoListApi();
      }
      this.getPartnerListApi();
    },
    // 姓名切换
    onNameChange(row, v, index) {
      if (!row.fankeId) this.getApplyDaysApi(index);
    },
    // 开始时间切换
    onDateChange(v, index) {

      let startdate, startcan, enddate, endcan;
      let arr = [['startdate', "startcan", 'enddate', 'endcan'],
      ['tinghuodate', "tinghuocan", 'shouhuodate', 'shouhuocan'],
      ['qihuodate', 'qihuocan', 'tinghuodate', 'tinghuocan']
      ]

      startdate = this[`form${this.current}`]['data'][index][arr[this.current - 1][0]];
      startcan = this[`form${this.current}`]['data'][index][arr[this.current - 1][1]];
      enddate = this[`form${this.current}`]['data'][index][arr[this.current - 1][2]];
      endcan = this[`form${this.current}`]['data'][index][arr[this.current - 1][3]];

      if (startdate && startcan >= 0 && enddate && endcan >= 0) {
        let startdateD = startdate.getTime();
        let enddateD = enddate.getTime();
        console.log('判断时间', startdateD, enddateD, startdateD == enddateD, endcan);

        let startcanD = this.mealParams.filter((val, ind) => ind <= startcan)
        let endcanD = this.mealParams.filter((val, ind) => ind <= endcan)
        console.log(startdateD > enddateD);
        console.log('日期', (!isNaN(endcan)), (endcan || endcan === 0));
        console.log('餐段判断', endcan, startcan, !isNaN(endcan));
        if ((startdateD > enddateD) || ((startdateD == enddateD) && ((startcan > endcan) && (endcan || endcan === 0)))) {

          console.log(2345);
          setTimeout(() => {
            this[`form${this.current}`]['data'][index][arr[this.current - 1][2]] = '';
            this[`form${this.current}`]['data'][index][arr[this.current - 1][3]] = '';
          }, 100);

          this.$Message.error("停火时间不能小于起火时间");
          return
        }
        let startcanS = 0;                        // 开始餐次时间
        let endcanS = 0;
        console.log(startcan);                        // 结束餐次时间
        console.log('餐次', this.mealParams, startcan);
        // 第一天的时间
        startcanS = startcan ? startcan == 1 ? this.mealParams[1] + this.mealParams[2] : this.mealParams[2] : this.mealParams[0] + this.mealParams[1] + this.mealParams[2]
        // startcanD.forEach(val => {
        //   startcanS += val;
        // });
        endcanD.forEach(val => {
          endcanS += val;
        })
        console.log('时间', startcanS, (enddateD - startdateD) / 86400000, endcanS);
        this[`form${this.current}`]['data'][index]['days'] = ((enddateD - startdateD) / 86400000 + endcanS + startcanS - 1).toFixed(2);

        if (this.current == 3 && this[`form3`]['data'][index]['lianxiname']) {
          let cansT = this[`form3`]['data'][index]['cansT'] ? this[`form3`]['data'][index]['cansT'] : 0;
          this[`form3`]['data'][index]['cans'] = (cansT - this[`form${this.current}`]['data'][index]['days']).toFixed(2);
        }
      }
      if (this.current == 1) {
        let money = this[`form${this.current}`].data[index].standardmoney + this[`form${this.current}`].data[index].jbmoney
        this[`form${this.current}`].data[index].money = (money * (this[`form${this.current}`].data[index].days > 0 ? Number(this[`form${this.current}`].data[index].days) : 0)).toFixed(2);;
      }
      if (this.current == 2) {
        let money = this[`form${this.current}`].data[index].hsmoney + this[`form${this.current}`].data[index].jbmoney + this[`form${this.current}`].data[index].sickpersonnelstandard
        this[`form${this.current}`].data[index].tuihuomoney = (money * (this[`form${this.current}`].data[index].days > 0 ? Number(this[`form${this.current}`].data[index].days) : 0)).toFixed(2);;
      }
      if (this.current == 3) {
        console.log('修改金额');
        console.log(this.form3.data[index], 7878)
        let num = Number(this.form3.data[index].cans)

        if (num < 0) {

          setTimeout(() => {
            this.form3.data[index][arr[this.current - 1][2]] = '';
            this.form3.data[index].cans = this.form3.data[index].cansT
            this.form3.data[index].days = ""
          }, 100);
          this.$Message.error("选择日期大于剩余天数");
        }
        // console.log(num, 78788)
        console.log('修改金额',this[`form${this.current}`].data[index].standardmoney, this[`form${this.current}`].data[index].guojieMoney, this[`form${this.current}`].data[index].days * 1,this[`form${this.current}`].data[index].guojie * 1);
        let guojieMoney = this[`form${this.current}`].data[index].standardmoney * this[`form${this.current}`].data[index].days 
        let standardmoney =this[`form${this.current}`].data[index].guojieMoney  * this[`form${this.current}`].data[index].guojie
        console.log('修改金额',guojieMoney,standardmoney);
        this[`form${this.current}`].data[index].money = (guojieMoney + standardmoney).toFixed(2);
      }
      this.$nextTick(() => {
        this.getPartnerListApi()
      })

    },
    // tabs点击事件
    onTabClick(v) {
      this.current = v;
      this.$nextTick(() => this.onInit());
    },
    // 交伙类型切换
    onTypeChange(row, level, index, v, isClear) {
      console.log(row);
      let typeIndex = v ? row.partnerList.indexOf(row.partnerList.find(item => {
        return item.name == v
      })) : 0
      if (
        (!row.jiaohuoId && this.current == 1) ||
        (!row.tuihuoId && this.current == 2) ||
        (!row.fankeId && this.current == 3)
      )
        // 
        this.$set(this[`form${this.current}`], this[`form${this.current}`].data[index].standardstr, row.standardstr)
      // 类型转换需要清空标准选项
      if (isClear) {
        this.$nextTick(() => {
          for (let item of this.$refs[`formValidate${this.current}`].fields) {    //form为表单的ref名称，fields为该表单下需要验证的所有字段，tarKeyArr为需要重置的所有字段
            if (`data.${index}.standardstr`.indexOf(item.prop) !== -1) {
              console.log(1);
              item.resetField()
            }
          }
        })
        console.log('清空', this.$refs[`formValidate${this.current}`]);

      }
      // console.log('清空后',this.form1.data[index].standardstr);

      // }
      console.log(234567);
      this.getPartnerListApi(level, index, typeIndex, isClear)
    },
    // 新增登记
    onAdd(row, index) {
      console.log(22222, this.current);
      console.log(this.$refs[`formValidate${this.current}`]);
      if (this.current == 1) {
        this.$nextTick(() => {
          this.$refs[`formValidate1`].validate(valid => {
            console.log('222', valid);
            if (valid) {

              this.form1.data.push({
                columns1: "",
                jiaohuoname: "",
                type: "",
                subject: "",
                jhabstract: "",
                standardstr: "",
                startdate: "",
                startcan: "",
                enddate: "",
                endcan: "",
                days: "",
                standardmoney: "",
                jbmoney: "",
                money: "",
                partnerList: [], // 交伙标准列表(2级列表)
                options: {
                  disabledDate: date => {
                    return date && date.valueOf() < Date.now() - 86400000;
                  }
                }

              })

            }
          })
        });
      } else if (this.current == 2) {
        this.$nextTick(() => {
          this.$refs[`formValidate2`].validate(valid => {
            if (valid) {

              this.form2.data.push({
                columns1: "",
                jiaohuoname: "",
                type: "",
                subject: "",
                thabstract: "",
                tinghuodate: "",
                tinghuocan: "",
                standardstr: "",
                shouhuodate: "",
                shouhuocan: "",
                days: "",
                hsmoney: "",
                jbmoney: "",
                tuihuomoney: "",
                partnerList: [], // 交伙标准列表(2级列表)
                options: {
                  disabledDate: date => {
                    return date && date.valueOf() < Date.now() - 86400000;
                  }
                }
              });


            }
          })
        })
      } else if (this.current == 3) {
        this.$nextTick(() => {
          this.$refs[`formValidate3`].validate(valid => {
            if (valid) {

              this.form3.data.push({
                columns1: "",
                lianxiname: "",
                fankename: "",
                standardstr: "",
                fkabstract: "",
                tinghuodate: "",
                tinghuocan: "",
                qihuodate: "",
                qihuocan: "",
                days: "",
                cans: "",
                guojie: 0,
                standardmoney: "",
                jbmoney: "",
                guojieMoney: "",
                money: "",
                partnerList: [], // 交伙标准列表(2级列表)
                options: {
                  disabledDate: date => {
                    return date && date.valueOf() < Date.now() - 86400000;
                  }
                }

              });


              this.getPartnerListApi(2, this.form3.data.length - 1);
            }
          })
        })
      }
      // this.$refs[`formValidate${this.current}`].validate(valid => {
      //   console.log('222',valid);
      // if (valid) {
      //     if (this.current == 1) {

      //   console.log(11122);
      // } else if (this.current == 2) {
      //   this.form2.data.push({
      //     columns1: "",
      //     jiaohuoname: "",
      //     type: "",
      //     subject: "",
      //     thabstract: "",
      //     tinghuodate: "",
      //     tinghuocan: "",
      //     shouhuodate: "",
      //     shouhuocan: "",
      //     days: "",
      //     hsmoney: "",
      //     jbmoney: "",
      //     tuihuomoney: "",
      //     partnerList: [], // 交伙标准列表(2级列表)
      //     options: {
      //       disabledDate: date => {
      //         return date && date.valueOf() < Date.now() - 86400000;
      //       }
      //     }
      //   });
      // } else if (this.current == 3) {
      //   this.form3.data.push({
      //     columns1: "",
      //     lianxiname: "",
      //     fankename: "",
      //     standardstr: "",
      //     fkabstract: "",
      //     tinghuodate: "",
      //     tinghuocan: "",
      //     qihuodate: "",
      //     qihuocan: "",
      //     days: "",
      //     cans: "",
      //     guojie: 0,
      //     standardmoney: "",
      //     jbmoney: "",
      //     guojieMoney: "",
      //     money: "",
      //     partnerList: [], // 交伙标准列表(2级列表)
      //     options: {
      //       disabledDate: date => {
      //         return date && date.valueOf() < Date.now() - 86400000;
      //       }
      //     }
      //   });
      //   this.getPartnerListApi(2, this.form3.data.length - 1);

      // }
      // }
      // })
    },
    // 保存
    onSave() {
      this.$refs[`formValidate${this.current}`].validate(valid => {
        if (valid) {
          this.$cu
            .dialog({ content: "确认保存登记操作", title: "提示" })
            .then(() => {
              this.form0.loading = true;
              if (this.current == 1) {
                this.addPartnerApi();
              } else if (this.current == 2) {
                this.addCancelPartnerApi();
              } else if (this.current == 3) {
                this.addFanKeApi();
              }
            });
        }
      });
    },
    // 获取二级类型
    getPartnerListApi(level, index, typeIndex = 0, isClear = false) {
      console.log('级别', level);
      return new Promise((resolve, reject) => {
        let personnelType;
        let standardstr;
        if (isClear) {
          console.log(222222);
        }
        if (this.current == 3) {
          personnelType = "义务兵";
          if (!level) personnelType = "";
        } else if (level) {
          personnelType = this[`form${this.current}`]["data"][index]["type"];
          standardstr = this[`form${this.current}`]["data"][index][
            "standardstr"
          ];
        } else {
          personnelType = "";
          standardstr = "";
        }

        getPartnerList({
          settingType: this.current,
          personnelType: personnelType,
          subject: isClear ? '' : standardstr
        }).then(res => {
          if (res.errorcode === 0) {
            console.log(level);
            if (!level) {
              res.foodSettingList = res.foodSettingList.map(val => {
                val.name = val.personnelType;
                val.id = val.personnelType;
                return val;
              })
              this.danweiList = res.foodSettingList;
              return;
            }

            if (level === 2) {
              console.log('进来1');
              res.foodSettingList = res.foodSettingList.map(val => {
                val.name = val.subject;
                val.id = val.subject;
                return val;
              })
              this[`form${this.current}`].data[index].partnerList = this.$cu.deepClone(res.foodSettingList);
            } else if (level === 3) {
              if (res.foodSettingList.length) {
                console.log(res.foodSettingList);
                let standardmoney = res.foodSettingList[typeIndex]['standard'] ? res.foodSettingList[typeIndex]['standard'] : 0;
                let jbmoney = res.foodSettingList[typeIndex]['differentialSubsidy'] ? res.foodSettingList[typeIndex]['differentialSubsidy'] : 0;
                let sickPersonnelStandard = res.foodSettingList[typeIndex]['sickPersonnelStandard'] ? res.foodSettingList[typeIndex]['sickPersonnelStandard'] : 0;
                let money = res.foodSettingList[typeIndex]['total'] ? res.foodSettingList[0]['total'] : 0;
                let holidaySubsidyStandard = res.foodSettingList[typeIndex]['holidaySubsidyStandard'] ? res.foodSettingList[typeIndex]['holidaySubsidyStandard'] : 0;
                if (this.current == 1) {
                  this[`form${this.current}`].data[index].standardmoney = standardmoney;
                  this[`form${this.current}`].data[index].jbmoney = jbmoney;
                  console.log('111', Number(this[`form${this.current}`].data[index].days), money);
                  this[`form${this.current}`].data[index].money = (money * (this[`form${this.current}`].data[index].days > 0 ? Number(this[`form${this.current}`].data[index].days) : 0)).toFixed(2);
                } else if (this.current == 2) {
                  this[`form${this.current}`].data[index].hsmoney = standardmoney;
                  this[`form${this.current}`].data[index].jbmoney = jbmoney;
                  this[`form${this.current}`].data[index].sickpersonnelstandard = sickPersonnelStandard;
                  this[`form${this.current}`].data[index].tuihuomoney = (money * (this[`form${this.current}`].data[index].days > 0 ? Number(this[`form${this.current}`].data[index].days) : 0)).toFixed(2);;

                } else if (this.current == 3) {
                  this[`form${this.current}`].data[index].standardmoney = standardmoney;
                  this[`form${this.current}`].data[index].guojieMoney = holidaySubsidyStandard;
                  console.log(this[`form${this.current}`].data[index]);
                  this[`form${this.current}`].data[index].money = (money * (this[`form${this.current}`].data[index].days > 0 ? Number(this[`form${this.current}`].data[index].days) : 0)).toFixed(2);;
                }
              }
              console.log('调取后', this.form1.data[index].standardstr);
            }
          }
        })
      })
    },
    // 获取就餐参数
    getDinnerParamsApi() {
      return new Promise((resolve, reject) => {
        getDinnerParams({}).then(res => {
          if (res.errorcode === 0) {
            this.mealParams = [res.breakfast, res.lunch, res.dinner];
          }
        });
      });
    },
    // 获取可报销天数
    getApplyDaysApi(index) {
      return new Promise(resolve => {
        getApplyDays({
          name: this.form3.data[index].lianxiname
        }).then(res => {
          if (res.errorcode === 0) {
            let days = this.form3.data[index]["days"]
              ? this.form3.data[index]["days"]
              : 0;
            this.form3.data[index].cansT = res.days;
            this.form3.data[index].cans = res.days - days;
          }
        });
      });
    },
    // 获取交伙登记列表
    getPartnerInfoListApi() {
      this.form1.loading = true;
      return new Promise((resolve, reject) => {
        getPartnerInfoList({
          type: this.form0.type,
          jiaoHuoName: this.form0.jiaoHuoName,
          current: this.pages1.page,
          size: this.pages1.pageSize,
          startDate: this.form0.startTime,
          endDate: this.form0.endTime
        }).then(res => {
          this.form1.loading = false;
          if (res.errorcode === 0) {
            res.jiaoHuoList.map(v => {
              v.startdate = new Date(v.startdate).Format("yyyy-MM-dd");
              v.enddate = new Date(v.enddate).Format("yyyy-MM-dd");
              return v;
            });
            this.form1.data = res.jiaoHuoList;
            this.form1.total = res.total;
            this.pages1.pageTotal = res.totalcount;
            this.onAdd();
          }
        });
      });
    },
    // 获取停火登记列表
    getCancelPartnerInfoListApi() {
      this.form2.loading = true;
      return new Promise((resolve, reject) => {
        getCancelPartnerInfoList({
          type: this.form0.type,
          tuiHuoName: this.form0.jiaoHuoName,
          current: this.pages2.page,
          size: this.pages2.pageSize,
          startDate: this.form0.startTime,
          endDate: this.form0.endTime
        }).then(res => {
          this.form2.loading = false;
          if (res.errorcode === 0) {
            res.jiaoHuoList.map(v => {
              v.shouhuodate = new Date(v.shouhuodate).Format("yyyy-MM-dd");
              v.tinghuodate = new Date(v.tinghuodate).Format("yyyy-MM-dd");
              return v;
            });
            this.form2.data = res.jiaoHuoList;
            this.form2.total = res.total;
            this.pages2.pageTotal = res.totalcount;
            this.onAdd();
          }
        });
      });
    },
    // 获取饭客登记列表
    getFanKeInfoListApi() {
      this.form3.loading = true;
      return new Promise((resolve, reject) => {
        getFanKeInfoList({
          type: this.form0.type,
          name: this.form0.jiaoHuoName,
          current: this.pages3.page,
          size: this.pages3.pageSize,
          startDate: this.form0.startTime,
          endDate: this.form0.endTime
        }).then(res => {
          this.form3.loading = false;
          if (res.errorcode === 0) {
            res.jiaoHuoList.map(v => {
              v.qihuodate = new Date(v.qihuodate).Format("yyyy-MM-dd");
              v.tinghuodate = new Date(v.tinghuodate).Format("yyyy-MM-dd");
              return v;
            });
            this.form3.data = res.jiaoHuoList;
            this.form3.total = res.total;
            this.pages3.pageTotal = res.totalcount;
            this.onAdd();
          }
        });
      });
    },
    // 新增交伙登记
    addPartnerApi() {
      return new Promise((resolve, reject) => {
        let timeF = true;
        let jiaoHuoList = this.form1.data.filter(v => !v.jiaohuoId);
        console.log(jiaoHuoList);
        jiaoHuoList.map(v => {
          v.startDateStr = v.startdate.Format("yyyy-MM-dd");
          v.endDateStr = v.enddate.Format("yyyy-MM-dd");
          v.type = v.type;
          if (v.days < 0) timeF = false;
          return v;
        });
        if (!timeF) {
          this.form0.loading = false;
          return this.$Message.error("停火时间与餐次不能小于起火时间与餐次");
        }
        addPartner({
          jiaoHuoList: JSON.stringify(jiaoHuoList)
        })
          .then(res => {
            this.form0.loading = false;
            if (res.errorcode === 0) {
              this.$Message.success("新增成功");
              this.onInit();
            }
          })
          .catch(err => {
            this.form0.loading = false;
          });
      });
    },
    // 新增退伙登记
    addCancelPartnerApi() {
      return new Promise((resolve, reject) => {
        let tuiHuoList = this.form2.data.filter(v => !v.tuihuoId);
        let timeF = true;
        tuiHuoList.map(v => {
          v.tingHuoDateStr = v.tinghuodate.Format("yyyy-MM-dd");
          v.shouHuoDateStr = v.shouhuodate.Format("yyyy-MM-dd");
          v.type = v.type;
          if (v.days < 0) timeF = false;
          return v;
        });
        if (!timeF) {
          this.form0.loading = false;
          return this.$Message.error("停火时间与餐次不能小于起火时间与餐次");
        }

        addCancelPartner({
          tuiHuoList: JSON.stringify(tuiHuoList)
        })
          .then(res => {
            this.form0.loading = false;
            if (res.errorcode === 0) {
              this.$Message.success("新增成功");
              this.onInit();
            }
          })
          .catch(err => {
            this.form0.loading = false;
          });
      });
    },
    // 新增客饭登记
    addFanKeApi() {
      return new Promise((resolve, reject) => {
        let fanKeList = this.form3.data.filter(v => !v.fankeId);
        let timeF = true;
        fanKeList.map(v => {
          v.qihuodatestr = v.qihuodate.Format("yyyy-MM-dd");
          v.tinghuodatestr = v.tinghuodate.Format("yyyy-MM-dd");
          if (v.days < 0) timeF = false;
          return v;
        });

        // 检测是否存在同名用户
        const newArr = fanKeList.reduce(function (tempArr, item) {
          if (
            tempArr.findIndex(ele => ele.lianxiname === item.lianxiname) === -1
          ) {
            tempArr.push(item);
          }
          return tempArr;
        }, []);

        if (newArr.length !== fanKeList.length) {
          this.form0.loading = false;
          return this.$Message.error("不允许存在同名姓名,请检阅");
        }

        if (!timeF) {
          this.form0.loading = false;
          return this.$Message.error("停火时间与餐次不能小于起火时间与餐次");
        }

        addFanKe({
          fanKeList: JSON.stringify(fanKeList)
        })
          .then(res => {
            this.form0.loading = false;
            if (res.errorcode === 0) {
              this.$Message.success("新增成功");
              this.onInit();
            }
          })
          .catch(err => {
            this.form0.loading = false;
          });
      });
    },
  }
};
</script>

<style scoped lang="scss">
.withdrawRegister {
  position: relative;
}

.cookTable-item {
  padding-top: 24px;

  &-opera {
    width: 100%;
  }
}
</style>
